/**
 * Created by 周翔 on 2017/5/10.
 */
/**
 * Created by 周翔 on 2017/3/30.
 */
import http from '../../../common/httpUtil';
import * as types from './operationContentMutationTypes';



const actions = {
  queryOperationContent ({ commit }) {
    commit(types.OPERATION_CONTENT_QUERY_BEGIN);
    return http.get('sys/oc/all').then(operationContents => {
      console.log(operationContents)
      commit(types.OPERATION_CONTENT_QUERY_SUC, {operationContents});
    })
  },
  saveOperationContent({ commit }, operationContent) {
    return http.post('sys/oc/add', operationContent).then(operationContent => {
      commit(types.OPERATION_CONTENT_ADD_SUC, {operationContent})
    });
  },


  updateOperationContent({ commit }, operationContent) {
    return http.post('sys/oc/update', operationContent).then(data => {
      commit(types.OPERATION_CONTENT_UPDATE_SUC, {operationContent})
    });
  },

  deleteOperationContent({ commit }, { id } = {}) {
    commit(types.OPERATION_CONTENT_DELETE_BEGIN);

    return http.get(`sys/oc/delete?id=${id}`).then(data => {
      commit(types.OPERATION_CONTENT_DELETE_SUC, {id});
    });
  },
  onlineOperationContent({ commit }, operationContent) {
    commit(types.OPERATION_CONTENT_ONLINE_BEGIN, {operationContent});
    return http.post('sys/oc/online', operationContent).then(data => {
      commit(types.OPERATION_CONTENT_ONLINE_SUC, {operationContent});
    });
  }
}


export default actions;
